package com.more.spring.boot.springmybatisdemo;

import com.more.spring.boot.springmybatisdemo.config.DataSourceConfig;
import com.more.spring.boot.springmybatisdemo.config.MyBatisConfig;
import com.more.spring.boot.springmybatisdemo.config.MyBatisMapperScanConfig;
import com.more.spring.boot.springmybatisdemo.config.TransactionConfig;
import com.more.spring.boot.springmybatisdemo.pojo.User;
import com.more.spring.boot.springmybatisdemo.service.UserService;
import com.more.spring.boot.springmybatisdemo.service.impl.UserServiceImpl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.List;


public class Main {

    public static void main(String[] args) {
      /*  ApplicationContext context = new AnnotationConfigApplicationContext(
                DataSourceConfig.class,
                MyBatisConfig.class,
                MyBatisMapperScanConfig.class,
                TransactionConfig.class
        );*/

        ApplicationContext context = new AnnotationConfigApplicationContext(
                "com.more.spring.boot.springmybatisdemo" // 扫描整个包
        );

        UserService userService = context.getBean(UserService.class);
        List<User> users = userService.queryUsers();
        for (User user : users) {
            System.out.println(user);
        }
    }
}
